<template>
	<view>
		<!-- 用户 -->
		<view class="userbox flex ac">
			<view class="userimage" @click="gere">
				<image mode="aspectFill" :src="user.picture"></image>
			</view>
			<view @click="gere" style="flex:1;margin-left: 15rpx;">
				<view class="username">{{user.name}}</view>
				<view class="user-id">ID：{{user.open_id}}</view>
			</view>
			<view class="flex ac">
				<image @click="taskdata" style="width: 100rpx;" mode="widthFix"
					src="https://duimianimg.loovee.com/style/img/h5/jww/h51710212143859/img/mzs_gr_icon_mingrifuli.4467a2a.gif">
				</image>
				<image @click="gere" style="width: 30rpx;height: 30rpx;" src="../../static/icon/right.png"></image>
			</view>
		</view>

		<!-- 多少 -->
		<view class="num-info flex flex ac">
			<view class="num-info-box flex ac jc fc">
				<view class="num-info-num">{{user.currency}}</view>
				<view class="num-info-text">金币</view>
			</view>
			<view @click="wawa" class="num-info-box flex ac jc fc">
				<view class="num-info-num">{{user.doll_count}}</view>
				<view class="num-info-text">娃娃</view>
			</view>
			<view @click="integral" class="num-info-box flex ac jc fc">
				<view class="num-info-num">{{user.accumulate}}</view>
				<view class="num-info-text">积分</view>
			</view>
			<!-- <view class="num-info-box flex ac jc fc">
				<view class="num-info-num">0</view>
				<view class="num-info-text">卡包卷</view>
			</view> -->
		</view>

		<!-- 我的订单 -->
		<view class="orderformbox">
			<view class="orderformtitle flex ac">
				<view class="orderformtitle-title" style="flex: 1;">我的订单</view>
				<view class="flex ac" @click="orderdata(0)">
					<view class="orderformtitle-right">全部订单</view>
					<image style="width: 30rpx;height: 30rpx;" src="../../static/icon/right.png"></image>
				</view>
			</view>
			<view class="orderlist flex">
				<view class="orderview flex ac jc fc" @click="orderdata(1)">
					<image src="../../static/icon/icon1.png"></image>
					<view class="order-text">待发货</view>
				</view>
				<view class="orderview flex ac jc fc" @click="orderdata(2)">
					<image src="../../static/icon/icon2.png"></image>
					<view class="order-text">待收货</view>
				</view>
				<view class="orderview flex ac jc fc" @click="orderdata(3)">
					<image src="../../static/icon/icon3.png"></image>
					<view class="order-text">已重发</view>
				</view>
				<view class="orderview flex ac jc fc" @click="orderdata(4)">
					<image src="../../static/icon/icon4.png"></image>
					<view class="order-text">已完成</view>
				</view>
				<view class="orderview flex ac jc fc" @click="aftersales">
					<image src="../../static/icon/icon5.png"></image>
					<view class="order-text">售后</view>
				</view>
			</view>
		</view>

		<!-- 跳转其他区域 -->
		<view class="imagebox">
			<view @click="ranking" class="imagelist" style="margin-bottom: 10rpx;">
				<image mode="widthFix"
					src="https://duimianimg.loovee.com/MediaServerMblove/servlet/Proxy/PhotoServlet/FrCaLtGciWfkGHiie3cpqyGj1f1w.png">
				</image>
			</view>
			<view @click="integral" class="imagelist" style="margin-bottom: 10rpx;">
				<image mode="widthFix"
					src="https://duimianimg.loovee.com/MediaServerMblove/servlet/Proxy/PhotoServlet/FmRXM9FZQ5C8VvVk0bJPxevqzZ9T.png">
				</image>
			</view>
<!-- 			<view class="imagelist">
				<image mode="widthFix"
					src="https://duimianimg.loovee.com/MediaServerMblove/servlet/Proxy/PhotoServlet/FrCaLtGciWfkGHiie3cpqyGj1f1w.png">
				</image>
			</view>
			<view class="imagelist">
				<image mode="widthFix"
					src="https://duimianimg.loovee.com/MediaServerMblove/servlet/Proxy/PhotoServlet/FmRXM9FZQ5C8VvVk0bJPxevqzZ9T.png">
				</image>
			</view> -->
		</view>

		<!-- 我的服务 -->
		<view class="servicebox">
			<view class="servicetitle flex ac">
				<view class="servicetitle-title" style="flex: 1;">我的服务</view>
			</view>
			<view class="servicelist">
				<view @click="taskdata" class="serviceview flex ac jc fc margin-bottom-20">
					<view class="serviceview-image">
						<image src="../../static/icon/aa/list1.png"></image>
					</view>
					<view class="serviceview-text">任务奖励</view>
				</view>
				<view @click="activitydata" class="serviceview flex ac jc fc margin-bottom-20">
					<view class="serviceview-image">
						<image src="../../static/icon/aa/list2.png"></image>
					</view>
					<view class="serviceview-text">活动中心</view>
				</view>
				<view class="serviceview flex ac jc fc margin-bottom-20" @click="recorddata">
					<view class="serviceview-image">
						<image src="../../static/icon/aa/list2.png"></image>
					</view>
					<view class="serviceview-text">游戏记录</view>
				</view>
				<view class="serviceview flex ac jc fc margin-bottom-20">
					<view class="serviceview-image">
						<image src="../../static/icon/aa/list3.png"></image>
					</view>
					<view class="serviceview-text">在线客服</view>
				</view>
				<view @click="address" class="serviceview flex ac jc fc margin-bottom-20">
					<view class="serviceview-image">
						<image src="../../static/icon/aa/list4.png"></image>
					</view>
					<view class="serviceview-text">收货地址</view>
				</view>
				<view @click="helpcenter" class="serviceview flex ac jc fc margin-bottom-20">
					<view class="serviceview-image">
						<image src="../../static/icon/aa/list5.png"></image>
					</view>
					<view class="serviceview-text">帮助中心</view>
				</view>
				<view @click="messagecenter" class="serviceview flex ac jc fc margin-bottom-20">
					<view class="serviceview-image">
						<image src="../../static/icon/aa/list6.png"></image>
					</view>
					<view class="serviceview-text">消息中心</view>
				</view>
				<view @click="setup" class="serviceview flex ac jc fc margin-bottom-20">
					<view class="serviceview-image">
						<image src="../../static/icon/aa/list7.png"></image>
					</view>
					<view class="serviceview-text">设置中心</view>
				</view>
				<view @click="feedbackdata" class="serviceview flex ac jc fc">
					<view class="serviceview-image">
						<image src="../../static/icon/aa/list8.png"></image>
					</view>
					<view class="serviceview-text">反馈建议</view>
				</view>
			</view>
		</view>

		<view style="width: 100%;height: 30rpx;"></view>

	</view>
</template>

<script>
	import {request} from "@/static/common.js";
	export default {
		data() {
			return {
				user: [],
			}
		},

		onLoad() {
			//没有登录跳转登录
			if (getApp().globalData.token == '') {
				uni.reLaunch({
					url: '/pages/login/login'
				})
				return
			}
			
			this.userinfodata()
		},

		methods: {
			async userinfodata(e) {
				//第一种
				// uni.request({
				// 	url: `${getApp().globalData.http}user/get_user_info`,
				// 	method: 'POST',
				// 	header: {
				// 		"Content-Type": "application/x-www-form-urlencoded"
				// 	},
				// 	data: {
				// 		token: app.globalData.token
				// 	},
				// 	success: (res) => {
				// 		console.log(res,"dada")
				// 	}
				// })

				let apply = await request(`${getApp().globalData.http}user/get_user_info`, {
					// "Content-Type": "application/x-www-form-urlencoded"
					'X-Requested-With': 'XMLHttpRequest',
					'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
				}, "POST", {
					token: getApp().globalData.token
				})
				if (apply.data.code == 0) {
					this.user = apply.data.data
				} else {
					uni.showToast({
						title: `${apply.data.message}`,
						icon: "none",
					})
				}

			},

			ranking(e) {
				uni.reLaunch({
					url: '/pages/rankinga/rankinga'
				})
			},

			taskdata(e) {
				uni.navigateTo({
					url: '/pages/taskcenter/taskcenter'
				})
			},

			address(e) {
				uni.navigateTo({
					url: '/pages/addresslist/addresslist'
				})
			},

			feedbackdata(e) {
				uni.navigateTo({
					url: '/pages/feedback/feedback'
				})
			},

			activitydata(e) {
				uni.navigateTo({
					url: '/pages/activity/activity'
				})
			},

			setup(e) {
				uni.navigateTo({
					url: '/pages/setup/setup'
				})
			},

			helpcenter(e) {
				uni.navigateTo({
					url: '/pages/helpcenter/helpcenter'
				})
			},

			messagecenter(e) {
				uni.navigateTo({
					url: '/pages/informationlist/informationlist'
				})
			},

			recorddata(e) {
				uni.navigateTo({
					url: '/pages/record/record'
				})
			},

			wawa(e) {
				uni.navigateTo({
					url: '/pages/doll/doll'
				})
			},

			integral(e) {
				uni.reLaunch({
					url: '/pages/exchange/exchange'
				})
			},

			orderdata(e) {
				var itemindex = e
				uni.navigateTo({
					url: '/pages/orderform/orderform?itemindex=' + e
				})
			},

			aftersales(e) {
				uni.navigateTo({
					url: '/pages/aftersales/aftersales'
				})
			},

			gere(e) {
				uni.navigateTo({
					url: '/pages/personal/personal'
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	@import url("my.css");
</style>